{{if gt .pagination.total 1}}
<div class="flex justify-center mt-10">
    <div class="inline-flex items-center rounded-lg bg-cyber-dark bg-opacity-60 backdrop-blur-sm border border-cyber-blue border-opacity-30">
        {{/* 上一页按钮 */}}
        {{if gt .pagination.current 1}}
        <a href="?page={{sub .pagination.current 1}}{{if .pagination.query}}&{{.pagination.query}}{{end}}" 
           class="relative inline-flex items-center px-3 py-2 text-sm font-rajdhani text-gray-300 hover:text-cyber-blue hover:bg-cyber-dark transition-all duration-300 rounded-l-lg">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                <path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
            </svg>
        </a>
        {{else}}
        <span class="relative inline-flex items-center px-3 py-2 text-sm font-rajdhani text-gray-600 rounded-l-lg">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                <path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
            </svg>
        </span>
        {{end}}
        
        {{/* 计算分页显示逻辑 */}}
        {{$current := .pagination.current}}
        {{$total := .pagination.total}}
        {{$maxButtons := 5}} {{/* 设置最多显示5个页码按钮 */}}
        
        {{/* 第1页总是显示 */}}
        <a href="?page=1{{if $.pagination.query}}&{{$.pagination.query}}{{end}}" 
           class="relative inline-flex items-center px-4 py-2 text-sm font-rajdhani border-r border-gray-700 {{if eq 1 $current}}bg-cyber-blue bg-opacity-10 text-cyber-blue font-medium{{else}}text-gray-300 hover:bg-cyber-blue hover:bg-opacity-10 hover:text-cyber-blue{{end}} transition-all duration-300">
            1
        </a>
        
        {{/* 计算页码范围 - 使用 GoFrame 支持的方式计算 */}}
        {{$startPage := 2}}
        {{$halfWindow := 1}} {{/* (5-3)/2 = 1，即中间页码数量的一半 */}}
        
        {{/* 如果当前页 > 2，需要计算起始页 */}}
        {{if gt $current 2}}
            {{if gt $current $halfWindow}}
                {{$startPage = sub $current $halfWindow}}
                {{if lt $startPage 2}}
                    {{$startPage = 2}}
                {{end}}
            {{end}}
        {{end}}
        
        {{/* 计算结束页 */}}
        {{$endPage := add $startPage 2}} {{/* 显示3个中间页码 */}}
        {{if gt $endPage (sub $total 1)}}
            {{$endPage = sub $total 1}}
            {{/* 如果结束页被调整，相应调整起始页，保证显示足够的页码 */}}
            {{if gt $endPage 2}}
                {{$startPage = sub $endPage 2}}
                {{if lt $startPage 2}}
                    {{$startPage = 2}}
                {{end}}
            {{end}}
        {{end}}
        
        {{/* 显示第一页与起始页之间的省略号 */}}
        {{if gt $startPage 2}}
        <span class="relative inline-flex items-center px-4 py-2 text-sm font-rajdhani text-gray-500 border-r border-gray-700">
            ...
        </span>
        {{end}}
        
        {{/* 显示中间的页码 - 使用条件判断实现循环 */}}
        {{if and (le $startPage (sub $total 1)) (ge $startPage 2)}}
            <a href="?page={{$startPage}}{{if $.pagination.query}}&{{$.pagination.query}}{{end}}" 
               class="relative inline-flex items-center px-4 py-2 text-sm font-rajdhani border-r border-gray-700 {{if eq $startPage $current}}bg-cyber-blue bg-opacity-10 text-cyber-blue font-medium{{else}}text-gray-300 hover:bg-cyber-blue hover:bg-opacity-10 hover:text-cyber-blue{{end}} transition-all duration-300">
                {{$startPage}}
            </a>
        {{end}}
        
        {{$middlePage := add $startPage 1}}
        {{if and (le $middlePage (sub $total 1)) (gt $middlePage 1)}}
            <a href="?page={{$middlePage}}{{if $.pagination.query}}&{{$.pagination.query}}{{end}}" 
               class="relative inline-flex items-center px-4 py-2 text-sm font-rajdhani border-r border-gray-700 {{if eq $middlePage $current}}bg-cyber-blue bg-opacity-10 text-cyber-blue font-medium{{else}}text-gray-300 hover:bg-cyber-blue hover:bg-opacity-10 hover:text-cyber-blue{{end}} transition-all duration-300">
                {{$middlePage}}
            </a>
        {{end}}
        
        {{$endPageShow := add $startPage 2}}
        {{if and (le $endPageShow (sub $total 1)) (gt $endPageShow 1)}}
            <a href="?page={{$endPageShow}}{{if $.pagination.query}}&{{$.pagination.query}}{{end}}" 
               class="relative inline-flex items-center px-4 py-2 text-sm font-rajdhani border-r border-gray-700 {{if eq $endPageShow $current}}bg-cyber-blue bg-opacity-10 text-cyber-blue font-medium{{else}}text-gray-300 hover:bg-cyber-blue hover:bg-opacity-10 hover:text-cyber-blue{{end}} transition-all duration-300">
                {{$endPageShow}}
            </a>
        {{end}}
        
        {{/* 显示结束页与最后页之间的省略号 */}}
        {{if lt $endPageShow (sub $total 1)}}
        <span class="relative inline-flex items-center px-4 py-2 text-sm font-rajdhani text-gray-500 border-r border-gray-700">
            ...
        </span>
        {{end}}
        
        {{/* 最后一页总是显示 */}}
        {{if gt $total 1}}
        <a href="?page={{$total}}{{if $.pagination.query}}&{{$.pagination.query}}{{end}}" 
           class="relative inline-flex items-center px-4 py-2 text-sm font-rajdhani {{if eq $total $current}}bg-cyber-blue bg-opacity-10 text-cyber-blue font-medium{{else}}text-gray-300 hover:bg-cyber-blue hover:bg-opacity-10 hover:text-cyber-blue{{end}} transition-all duration-300">
            {{$total}}
        </a>
        {{end}}
        
        {{/* 下一页按钮 */}}
        {{if lt .pagination.current .pagination.total}}
        <a href="?page={{add .pagination.current 1}}{{if .pagination.query}}&{{.pagination.query}}{{end}}" 
           class="relative inline-flex items-center px-3 py-2 text-sm font-rajdhani text-gray-300 hover:text-cyber-blue hover:bg-cyber-dark transition-all duration-300 rounded-r-lg">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
            </svg>
        </a>
        {{else}}
        <span class="relative inline-flex items-center px-3 py-2 text-sm font-rajdhani text-gray-600 rounded-r-lg">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
            </svg>
        </span>
        {{end}}
    </div>
</div>
{{end}} 